import React, { Component } from 'react';
import { ConfigProvider, Spin } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import moment from 'moment';
import AppRouter from './router/AppRouter';

moment.locale('zh-cn');
export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: true,
    };
  }

  componentDidMount() {
    setTimeout(() => {
      this.setState({
        loading: false,
      });
    }, 1000);
  }

  render() {
    const { loading } = this.state;
    return (
      <ConfigProvider locale={zhCN}>
        {loading ? (
          <div style={{
            display: 'flex',
            width: '100%',
            height: '100vh',
            alignItems: 'center',
            justifyContent: 'center',
          }}
          >
            <Spin spinning tip="加载中..." />
          </div>
        ) : <AppRouter />}
      </ConfigProvider>
    );
  }
}
